import { http } from "@/utils/http";

export type LoginAccountResult = {
  /** token */
  accessToken?: string;
  /** `accessToken`的过期时间（时间戳） */
  expiresIn: number;
  /** 用于调用刷新accessToken的接口时所需的token */
  refreshToken?: string;
  errorDescription?: string;
  identityToken?: string;
  issuedTokenType?: string;
  scope?: string;
  tokenType?: string;
};

export type SendCodeResult = {
  result: number;
  description?: string;
};

/** 登录获取token */
export const getLoginApi = (data?: object) => {
  return http.request<LoginAccountResult>(
    "post",
    "https://healthcheck.dev.hygeian.com.cn/cloud-services/api-identity/api/account/request-token-by-verification-code",
    { data }
  );
};

/** 刷新token */
export const refreshTokenApi = (data?: object) => {
  return http.request<LoginAccountResult>(
    "post",
    "https://healthcheck.dev.hygeian.com.cn/cloud-services/api-identity/api/account/refresh-token",
    { data }
  );
};

/** 发送验证码 */
export const SendCodeApi = (data?: object) => {
  return http.request<SendCodeResult>(
    "post",
    "https://healthcheck.dev.hygeian.com.cn/cloud-services/api-identity/api/account/send-verification-code",
    { data }
  );
};
